﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NHibernate.Audit.Cfg;
using NHibernate.Mapping;

namespace NHibernate.Audit.Contract.Cfg
{

    /// <summary>
    /// Contract for NHibernate.Audit.Cfg.IAuditClassConvention
    /// </summary>
    /// <remarks>
    /// Inherit this test fixture to prove an IAuditClassConvention implementation
    /// </remarks>
    public abstract class AuditClassConventionContract : AbstractContract<IAuditClassConvention>
    {

        protected override bool FixtureRequiresNHibernate()
        {
            return false;
        }

        protected override void Configure(NHibernate.Cfg.Configuration configuration)
        {
            // No mapping to load for these tests
        }


        [Test]
        public void can_create_entity_name_from_class_name()
        {
            var acc = ServiceLocator.GetInstance<IAuditClassConvention>();
            var testClass = new RootClass();
            testClass.ClassName = typeof(RevisionInfo<Guid>).FullName;
            Assert.IsNotNullOrEmpty(acc.GetAuditEntityNameFor(testClass));
        }

        [Test]
        public void can_create_entity_name_from_entity_name()
        {
            var acc = ServiceLocator.GetInstance<IAuditClassConvention>();
            var testClass = new RootClass();
            testClass.EntityName = typeof(RevisionInfo<Guid>).FullName;
            Assert.IsNotNullOrEmpty(acc.GetAuditEntityNameFor(testClass));
        }

        [Test]
        public void audit_class_name_is_not_null_or_empty()
        {
            var acc = ServiceLocator.GetInstance<IAuditClassConvention>();
            var testClass = new RootClass();
            testClass.ClassName = typeof(RevisionInfo<Guid>).FullName;
            Assert.IsNotNullOrEmpty(acc.GetAuditClassNameFor(testClass));
        }

    }
}
